

// let options = {kickReconnectDevice:true};
// let compressOptions = {
//   originalImageQuality: 80,
//   originalImageMaxSize: 1080,
//   originalImageSize: 200,
//   thumbnailQuality: 80,
//   thumbnailMaxSize: 500,
//   thumbnailMinSize: 200,
//   sightCompressHeight: 160,
//   sightCompressWidth: 160,
// };
//options.compressOptions = compressOptions;
// let engine = await RCIMIWEngine.create(appKey, options);

const rongyun = {
	namespaced:true,
	state: {
		engine:null,
		appkey: 'mgb7ka1nm2a7g',
		CONNECTED: false, // 是否连接
		conversationList: [], // 会话列表
		options: {}
	}, mutations: {
		async init() {
			console.log('state.engine------------',state.engine)
			state.engine = await RCIMIWEngine.create(state.appKey, state.options);
			console.log('tate.engine------------',state.engine)
			let callback = {
				onDatabaseOpened: (res) => {
					console.log('onDatabaseOpened------', res)
					//...
				},
				onConnected: (res) => {
					console.log('onConnected------', res)
					//...
				}
			};
			
			console.log('rongyun_tokenrongyun_token-----------',{rongyun_token:uni.getStorageSync('rongyun_token')})
			console.log('app_tokenapp_token-----------',{app_token:uni.getStorageSync('app_token')})
			let code = await state.engine.connect(uni.getStorageSync('rongyun_token'), 60, callback);
			
			//收到连接状态的回调
			state.engine.setOnDatabaseOpenedListener((res) => {
				console.log('setOnDatabaseOpenedListener------',res)
			    //...
			});
			
			//收到连接状态的回调
			state.engine.setOnConnectedListener((res) => {
				console.log('setOnConnectedListener------',res)
			    //...
			});
			
			//断开连接
			//let code = await engine.disconnect(receivePush);
			
			//监听连接状态
			state.engine.setOnConnectionStatusChangedListener((res) => {
				console.log('setOnConnectionStatusChangedListener------',res)
			    //...
			});
			
			//设置消息监听
			state.engine.setOnMessageReceivedListener((res) => {
				console.log('setOnMessageReceivedListener------',res)
			    //...
			});
			//退出登录
			// 断开链接，是否继续接收推送
			// let receivePush = true
			// let code = await yourEngine.disconnect(receivePush)
			
			
			//销毁引擎
			//let code = await yourEngine.destroy()
			
		}
	}, actions: {
		
		// setUser({ commit }, user) {
		// 	commit("SET_USER", user);
		// }
	}

};




export default rongyun